#include <reg52.h>

sbit dula = P2^6;
sbit wela = P2^7;

unsigned int t, n, w;

unsigned char code table[] = {
			0x3f, 0x06, 0x5b, 0x4f,
			0x66, 0x6d, 0x7d, 0x07,
			0x7f, 0x6f };

unsigned char code we_table[] = {
			0xfe, 0xfd, 0xfb, 0xf7,
			0xef, 0xdf, 0xbf, 0x7f };

void main()
{
	t = 0;
	n = 0;
	w = 0;
	
	TMOD = 0x01;
	TH0 = (65536 - 50000) / 256;
	TL0 = (65536 - 50000) % 256;
	EA = 1;
	ET0 = 1;
	TR0 = 1;
	
	wela = 1;
	P0 = 0xc0;
	wela = 0;
	
	dula = 1;
	P0 = 0x3f;
	dula = 0;
	while (1)
	{
		if (t == 20)
		{
			t = 0;
			n++;
			if (n == 10)
				n = 0;
			w++;
			if (w == 6)
				w = 0;
			
			dula = 1;
			P0 = table[n];
			dula = 0;
			
			wela = 1;
			P0 = we_table[w];
			wela = 0;
		}
	}
}

void timer0() interrupt 1
{
	TH0 = (65536 - 50000) / 256;
	TL0 = (65536 - 50000) % 256;
	t++;
}